<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>代扣列表 管理  没用到</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="addBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_3"></i>确认划扣</span>
                </div>
            </div>
        </form>
    </div>

    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null, menu = null;
    var callback = null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            /*url: '<%=path%>/capital/capFund/initList.do',
            parms:{fundCd:0},*/
            method: 'get',
            columns: [
                {display: '收款名称', name: 'acceptName', minWidth: 100, align: 'left', enabledSort: false},
                {display: '收款账号', name: 'acceptCode', minWidth: 100, align: 'left', enabledSort: false},
                {display: '到账日期', name: 'acceptDate', minWidth: 100, align: 'center', enabledSort: false,render:renderDate},
                {display: '凭证种类', name: 'certificateCd', minWidth: 100, align: 'left', enabledSort: false},
                {display: '凭证号码', name: 'certificateCode', minWidth: 100, align: 'left', enabledSort: false},
                {display: '企业业务编号', name: 'businessCode', minWidth: 100, align: 'left', enabledSort: false},
                {display: '来款账号', name: 'comeCode', minWidth: 100, align: 'left', enabledSort: false},
                {display: '来款户名', name: 'comeName', minWidth: 100, align: 'left', enabledSort: false},
                {display: '发生额', name: 'amount', minWidth: 100, align: 'right', enabledSort: false,
                    render:function(rowdata,index,value){
                        return FormatMoney(rowdata.amount/100);
                    }
                },
                {display: '创建时间', name: 'crtTm', minWidth: 100, align: 'center', enabledSort: false,render:renderDate},
                /*{display: '事业部', name: 'fundBelongOrgCd', minWidth: 100, align: 'left', enabledSort: false},*/
                {display: '操作', minWidth: 100, align: 'center', enabledSort: false,
                    render:function(rowdata,index,value){
                        if(!rowdata.usedAmount||rowdata.usedAmount==0){//可修改+废除
                           return "<a onclick='updateFund("+rowdata.id+")'>修改</a> | <a onclick='delFund("+rowdata.id+")'>废除</a>";
                        }
                        return;
                    }
                },
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "*Cd": " "
            });
        });
        
        callback = function () {
            grid.reload();
        };

        /* 新增 */
        $("#addBtn").click(function (event) {
            Add_navTab("CapFund_1", "资金录入", '<%=path%>/capital/capFund/toAddPage.do', callback);
        });

    });

    //修改
    function updateFund(id){
        Add_navTab('CapFund_2'+id, "资金修改", '<%=path%>/capital/capFund/toModifyPage.do?id='+id, callback);
    }
    //废除
    function delFund(id){
        var _ids = [id];
        $.ligerDialog.confirm("是否确认废除该笔资金?", function (flag) {
            if (flag == false)return;
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {ids: JSON.stringify(_ids)},
                url: '<%=path%>/capital/capFund/removeByIds.do',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({
                        content: LogUtils.LOG_CMM_DATA_LOADING,
                        SQ_type: "waitting"
                    });
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        grid.reload();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

    //批量导入
    function addBatch(){

    }

    //下载模板
    function downTemp(){

    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

</script>

</body>
</html>
